<?php
  /**
   * @author EVANDRO DE OLIVEIRA.
   * @category VIEW
   * @package VIEWS/SCRIPTS/CURSOS.
   * @since 21/07/2012.
   * @last_update 21/07/2012.
   * @copyright 2012.
   * @version 1.0.
   *
   */
?>
<table border="0" align="center" cellpadding="0" cellspacing="0" class="content-view">
  <tr>
    <td id="messenger" colspan="2"><?php echo $this->flashMessage();?></td>
  </tr>
  <tr>
    <td align="left" class="comp-title" style="width: 200px;">CONSULTA DE <?php echo $this->strTitleP?></td>  
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td class="watermark" align="center" colspan="2">
      <table border="0" align="center" cellpadding="0" cellspacing="0" width="100%" class="content-form">
        <tr>
          <td>
            <form name="form_search" method="post" action="">
              <table border="0" align="center" cellpadding="0" cellspacing="0">
                <tr>
                  <?php 
                    foreach($this->arrFilterFields as $strKey => $arrValues){
                    	?>
                    	<td align="right" class="label"><?php echo $strKey?>:</td>
                    	<td align="left">
                        <input type="<?php echo $arrValues['type']?>" name="<?php echo $arrValues['name']?>" id="<?php echo $arrValues['name']?>" maxlength="<?php echo $arrValues['maxlength']?>" style="width: <?php echo $arrValues['width']?>px;"/>
                      </td>
                      <td width="10"></td>
                    	<?php
                    }
                  ?>
                  <td align="left"><input type="submit" id="boton" value="Buscar"/></td>
                </tr>
              </table>
            </form>
          </td>
        </tr>
      </table>
      <table border="0" align="center" cellpadding="0" cellspacing="0" width="100%" class="content-form">
        <tr>
          <td>
            <div class="comp-button" style="cursor: pointer; width: 160px;" onclick="window.location='<?php echo $this->baseUrlController?>/add'">
              Inserir <u>N</u>ovo <?php echo $this->strTitleS?>
            </div>
          </td>
        </tr>
      </table>
      <table border="0" align="center" cellpadding="0" cellspacing="0" width="100%" class="content-form">
        <tr>
          <td>
            <form style='border:0; margin:0; padding:0;' name='lista_registros' action='' method='post'>
              <input id='idRegistro' name='idRegistro' value='' type='hidden'/>
              <table border="0" align="center" cellpadding="0" cellspacing="0" width="100%">
                <tr>
                  <?php 
                    foreach($this->arrTitleList as $strTitleList){
                    	?>
                      <td class="title-list"><?php echo $strTitleList?></td>  	
                    	<?php
                    }
                  ?>
                  <td class="title-list">Editar</td>
                  <td class="title-list">Excluir</td>
                </tr>
                <?php
                  if(count($this->paginator) > 0){
                  	foreach($this->paginator as $arrResult){
//Core_Commons::debugging($arrResult);                  		
                      if($arrResult['status'] == $this->intAtivo)
                        $objImg = '<img alt="ds_situacao" title="Ativo" src="' . $this->imagens . '/accept.png">';
                      else
                        $objImg = '<img alt="ds_situacao" title="Inativo"  src="' . $this->imagens . '/cancel.gif">';               
                      ?>
                      <tr>
                        <td class="result-list"><?php echo $arrResult['sigla']?></td>
                        <td class="result-list"><?php echo utf8_encode($arrResult['nome'])?></td>
                        <td class="result-list"><?php echo $objImg?></td>
                        <td class="result-list">
                          <a href="<?php echo $this->baseUrlController?>/editar/fl/<?php echo $arrResult['id']?>">
                            <img alt="editar" src="<?php echo $this->imagens?>/page_edit.png">
                          </a>
                        </td>
                        <td class="result-list">
                          <a href="<?php echo $this->baseUrlController?>/excluir/fl/<?php echo $arrResult['id']?>">
                            <img alt="excluir" src="<?php echo $this->imagens?>/delete.png">
                          </a>
                        </td>            
                      </tr>  
                      <?php
                    }
                  } 
                ?>
                <tr>
                  <td colspan='5' style="height: 25px;"></td>
                </tr>
                
                <tr>
                  <td colspan='5' class='td_6' align='center' valign='top'>
                    <?php echo $this->paginator?>
                  </td>
                </tr>
                
              </table>
            </form>
          </td>
        </tr>
      </table>          
    </td>
  </tr>            
</table>
<script type="text/javascript">
  function editarRegistro(intIdRegistro, strControllerName){
	  var strController = strControllerName;
    document.lista_registros.idRegistro.value = intIdRegistro;
    document.forms['lista_registros'].action = "<?=$this->baseUrl?>/" + strController + "/editar";
    document.lista_registros.submit();
  }
  
  function excluirRegistro(intIdRegistro, strControllerName){
    document.lista_registros.idRegistro.value = intIdRegistro;
    document.forms['lista_registros'].action = "<?=$this->baseUrl?>/" + strControllerName + "/excluir";
    document.lista_registros.submit();
  }
</script>  